package main

import (
	"fmt"
	"io"
	"log"
	"os"
	"time"
)
var Log *log.Logger
func InitLog(fileName string) {
	logFile, _ := os.Create("./"+time.Now().Format("20060102") + ".log")
	//defer logFile.Close()
	//初始化全局类型log
	log.SetFlags(log.Ldate | log.Lmicroseconds | log.Lshortfile)
	writers := []io.Writer{
		logFile,
		os.Stdout,
	}
	//让数据输出到控制台
	fileAndStdoutWriter := io.MultiWriter(writers...)
	//创建一个Logger
	//参数1：日志写入目的地
	//参数2：每条日志的前缀
	//参数3：日志属性
	Log = log.New(fileAndStdoutWriter, "", log.Ldate|log.Lmicroseconds|log.Lshortfile)
}

func main() {
	curTimeUnix := time.Now()
	fmt.Println(curTimeUnix)
	timeUnix := curTimeUnix.Unix() //时间戳
	fmt.Println(timeUnix)
	timeUnix = timeUnix *10000000
	fmt.Println(timeUnix)

	fmt.Println("sss", string(10))

	InitLog("test.log")

	Log.Printf("_________dsda%v", "3333333333")
	Log.Fatal("error")
}
